<template>
  <div id="app" class="writehomework" v-if="homework.ID">
    <i-panel
      header-class="writehomework-header"
      :title="title"
      :status="itembank.type"
      class="list"
    >
      <div class="html" style="padding:15rpx; height:350px;">
        <div v-html="itembank.text"></div>
      </div>
      <i-panel title="请填写答案" :use-footer-slot="true">
        <div style="padding:15px">
          <div class="text-center" v-if="itembank.type === '单选'">
            <i-button
              :type="data === vo?'info': ''"
              :round="true"
              v-for="(vo, io) in itembank.data[itembank.type]"
              @click="setanswer(vo)"
              :key="io"
              v-text="vo"
              custom-class="school-button-round"
            ></i-button>
          </div>
          <div class="text-center" v-else-if="itembank.type === '多选'">
            <div>
              <i-button
                :type="data[vo]?'info': ''"
                :round="true"
                v-for="(vo, io) in itembank.data[itembank.type]"
                @click="setanswer(vo)"
                :key="io"
                v-text="vo"
                custom-class="school-button-round"
              ></i-button>
            </div>
          </div>
          <div v-else-if="itembank.type === '填空'">
            <div v-for="(vo, io) in itembank.data[itembank.type]" style="margin-bottom: 6px;" :key="io">
              <div style="width:45px;" class="float-left">
                <i-button custom-class="school-button-round" round v-text="io+1" />
              </div>
              <div class="float-left" style="width:65%;">
                              <input
                style="height: 44px;line-height: 44px;border-radius: 22px;background:#eee;padding-left:15px;padding-right:15px;"
                class="school-input"
                @change="list"
                :id="io"
                placeholder="请输入答案"
                :value="data[io]"
              />
              </div>
              <i class="clearfix"></i>
            </div>
          </div>
          <div v-else>
            <textarea style="line-height: 26px;border-radius: 5px;background:#eee;padding-left:3px;padding-right:3px;" class="school-input"  placeholder="答案" v-model="textarea"  />
          </div>
        </div>
        <view slot="footer">
          <div style="display:flex;" class="text-center">
            <div style="flex:1;padding:15px;">
              <i-button
                :round="true"
                type="info"
                :block="true"
                @click="index===0?index:index--"
                :disabled="index===0"
              >上一题</i-button>
            </div>
            <div style="flex:1;padding:15px;">
              <i-button
                :round="true"
                type="info"
                :block="true"
                v-if="index != schoolhomeworkitembank.length-1"
                @click="index = index + 1"
              >下一题</i-button>
              <i-button
                :round="true"
                type="info"
                :block="true"
                v-if="index == schoolhomeworkitembank.length-1"
                @click="handleOpen2"
                :loading="loading"
                :disabled="loading"
              >提交答案</i-button>
            </div>
          </div>
        </view>
      </i-panel>
    </i-panel>
  </div>
</template>

<script>
import a from './a'
export default a
</script>
